/*
 * Copyright (c) United Binary LLC.  All rights reserved.
 * 
 * This code is licensed under the MIT License
 * 
 * SEE: http://harnessit.codeplex.com/license
 * 
 */
#region using ...
using System;
using System.Diagnostics;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
#endregion

namespace UnitedBinary.HarnessIt
{
	/// <summary>
	/// Summary description for LocalizationWarningForm.
	/// </summary>
	internal class LocalizationWarningForm : System.Windows.Forms.Form
	{
		#region Member Variables
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.ListBox listBoxBlockedFiles;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Button buttonOK;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label labelTempDir;
		private string [] blockedFiles = new string [0];
		#endregion

		#region Construction and Cleanup
		public LocalizationWarningForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// Add any constructor code after InitializeComponent call
			//

			PersistentValues pv = new PersistentValues();
			labelTempDir.Text = pv.InstallDirectory + "AssemblyTemp\\";
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.listBoxBlockedFiles = new System.Windows.Forms.ListBox();
			this.label3 = new System.Windows.Forms.Label();
			this.buttonOK = new System.Windows.Forms.Button();
			this.label4 = new System.Windows.Forms.Label();
			this.labelTempDir = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 27);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(424, 109);
			this.label1.TabIndex = 0;
			this.label1.Text = @"To solve a subtle shortcoming of .NET dynamic class invocation, HarnessIt creates temporary, local copies of all your test assemblies during test execution. Usually, these files are not used, but, under certain conditions, they are loaded and locked by the runtime and can not be updated automatically. The following list of temporary assemblies are currently locked and can not be updated with your latest changes. It is recommended that you restart HarnessIt to release the locks. You can continue running tests, but operations involving the listed files may have unexpected results.";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 193);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(100, 16);
			this.label2.TabIndex = 1;
			this.label2.Text = "Locked Files";
			// 
			// listBoxBlockedFiles
			// 
			this.listBoxBlockedFiles.Location = new System.Drawing.Point(8, 208);
			this.listBoxBlockedFiles.Name = "listBoxBlockedFiles";
			this.listBoxBlockedFiles.Size = new System.Drawing.Size(424, 121);
			this.listBoxBlockedFiles.TabIndex = 2;
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Location = new System.Drawing.Point(8, 9);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(424, 16);
			this.label3.TabIndex = 3;
			this.label3.Text = "A local copy of one or more assemblies is locked and needs to be updated";
			// 
			// buttonOK
			// 
			this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.buttonOK.Location = new System.Drawing.Point(356, 334);
			this.buttonOK.Name = "buttonOK";
			this.buttonOK.TabIndex = 4;
			this.buttonOK.Text = "OK";
			this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label4.Location = new System.Drawing.Point(8, 142);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(228, 16);
			this.label4.TabIndex = 5;
			this.label4.Text = "Temporary Assembly Directory:";
			// 
			// labelTempDir
			// 
			this.labelTempDir.Location = new System.Drawing.Point(8, 159);
			this.labelTempDir.Name = "labelTempDir";
			this.labelTempDir.Size = new System.Drawing.Size(420, 28);
			this.labelTempDir.TabIndex = 6;
			this.labelTempDir.Text = "TEMP_DIR";
			// 
			// LocalizationWarningForm
			// 
			this.AcceptButton = this.buttonOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.buttonOK;
			this.ClientSize = new System.Drawing.Size(438, 360);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.labelTempDir,
																		  this.label4,
																		  this.buttonOK,
																		  this.label3,
																		  this.listBoxBlockedFiles,
																		  this.label2,
																		  this.label1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "LocalizationWarningForm";
			this.ShowInTaskbar = false;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "HarnessIt Warning";
			this.Load += new System.EventHandler(this.LocalizationWarningForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		#region Windows Form Event Handlers
		private void buttonOK_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void LocalizationWarningForm_Load(object sender, System.EventArgs e)
		{
			listBoxBlockedFiles.Items.Clear();
			foreach(string f in BlockedFiles)
			{
				listBoxBlockedFiles.Items.Add(Path.GetFileName(f));
			}
		}
		#endregion

		#region File Properties
		public string [] BlockedFiles
		{
			get
			{
				return blockedFiles;
			}
			set
			{
				blockedFiles = value;
			}
		}
		#endregion
	}
}
